<template>
  <div class="container">
    <div class="screen" ref="screen">
      <div class="top">
        <Top />
      </div>
      <div class="bottom">
        <div class="left">
          <Tourist class="tourist"></Tourist>
          <Sex class="sex"></Sex>
          <Age class="age"></Age>
        </div>
        <div class="center">
          <Map class="map"></Map>
          <Line class="line"></Line>
        </div>
        <div class="right">
          <Rank class="rank"></Rank>
          <Year class="year"></Year>
          <Counter class="count"></Counter>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { Top } from './components/top/index';
import { Tourist } from './components/tourist/index';
import { Sex } from './components/sex/index';
import { Age } from './components/age/index';
import { Map } from './components/map/index';
import { Line } from './components/line/index';
import { Rank } from './components/rank/index';
import { Year } from './components/year/index';
import { Counter } from './components/couter/index';
import { ref, onMounted } from 'vue';

/*************自适应大屏开始***************/
let screen = ref<HTMLElement>();
onMounted(() => {
  screen.value!.style.transform = `scale(${getScale()}) translate(-50%, -50%)`;
});
function getScale(w: number = 1920, h: number = 1080) {
  const ww = window.innerWidth / w;
  const wh = window.innerHeight / h;
  return ww < wh ? ww : wh;
}
window.onresize = function () {
  screen.value!.style.transform = `scale(${getScale()}) translate(-50%, -50%)`;
};
/*************自适应大屏结束***************/
</script>
<style scoped lang="scss">
.container {
  width: 100vw;
  height: 100vh;
  background: url('@/assets/images/screen_images/bg.png') no-repeat;
  background-size: cover;

  .screen {
    width: 1920px;
    height: 1080px;
    position: fixed;
    left: 50%;
    top: 50%;
    transform-origin: left top;

    .top {
      width: 100%;
      height: 40px;
    }

    .bottom {
      display: flex;
      flex: 1;

      .left {
        flex: 1;
        height: 1040px;
        display: flex;
        flex-direction: column;

        .tourist {
          flex: 1;
        }

        .sex {
          flex: 1;
        }

        .age {
          flex: 1;
        }
      }

      .center {
        flex: 1.5;
        display: flex;
        flex-direction: column;

        .map {
          flex: 4;
        }

        .line {
          flex: 1;
        }
      }

      .right {
        flex: 1;
        display: flex;
        flex-direction: column;
        margin-left: 40px;

        .rank {
          flex: 1.5;
        }

        .year {
          flex: 1;
        }

        .count {
          flex: 1;
        }
      }
    }
  }
}
</style>
